// plugins/responsive-font-size.ts
import plugin from "tailwindcss/plugin";

interface ResponsiveFontSizeOptions {
  min?: string;
  max?: string;
  factor?: string;
}

/**
 * Tailwind CSS 插件：全局响应式 font-size 缩放（TS 版）
 * 默认 html { font-size: clamp(14px, 1vw + 12px, 18px) }
 */
export default plugin.withOptions<ResponsiveFontSizeOptions>(
  (options = {}) => {
    const min = options.min ?? "14px";
    const max = options.max ?? "18px";
    const factor = options.factor ?? "1vw + 12px";

    return ({ addBase }) => {
      addBase({
        html: {
          fontSize: `clamp(${min}, ${factor}, ${max})`
        }
      });
    };
  },
  () => ({
    theme: {}
  })
);
